import { configureStore } from '@reduxjs/toolkit'
import{  type TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
import {setupListeners} from '@reduxjs/toolkit/query'
import homepageReducer from './homepageSlice'; // 导入完善后的切片
import medicalContentReducer from './medicalContentSlice'; // 导入医疗内容切片
const store = configureStore({
  reducer: {
     homepage: homepageReducer,
     medicalContent: medicalContentReducer
  }
})

setupListeners(store.dispatch)
// 从 store 本身推断出 `RootState` 和 `AppDispatch` 类型
export type RootState = ReturnType<typeof store.getState>
// 推断出类型: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch
export const useAppDispatch: () => AppDispatch = useDispatch
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector

export default store